from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship

from ..db.base import Base, TimestampMixin

class Student(Base, TimestampMixin):
    """学生数据库模型"""
    __tablename__ = "students"

    id = Column(Integer, primary_key=True, index=True)
    user_id = Column(Integer, ForeignKey("users.id"), nullable=False, unique=True)
    academy = Column(String, nullable=False)
    major = Column(String, nullable=False)
    class_ = Column(String, nullable=False)

    # 关系
    user = relationship("User", back_populates="student")